<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var num = prompt('输入班级人数');
        var sum = 0;
        var avereage = 0;
        for (var i = 1; i <= num; i++) {
            var score = prompt('输入第' + i + '个学生成绩');
            //转换数据类型 将字符串转变为数字型
            sum += parseFloat(score);
        }
        avereage = sum / num;
        alert('总成绩' + sum + ';\n平均成绩' + avereage);
    </script>
</head>

<body>

</body>

</html>